/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cr.ac.una.sive.entidad;

import java.io.Serializable;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Collection;
import java.util.Date;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author claribel
 */
@Entity
@Table(name = "INCIDENTE", catalog = "", schema = "UNA_SIVE")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Incidente.findAll", query = "SELECT i FROM Incidente i"),
    @NamedQuery(name = "Incidente.findByIdIncidente", query = "SELECT i FROM Incidente i WHERE i.idIncidente = :idIncidente"),
    @NamedQuery(name = "Incidente.findByNombreRegistrante", query = "SELECT i FROM Incidente i WHERE i.nombreRegistrante = :nombreRegistrante"),
    @NamedQuery(name = "Incidente.findByDescripcion", query = "SELECT i FROM Incidente i WHERE i.descripcion = :descripcion"),
    @NamedQuery(name = "Incidente.findByHora", query = "SELECT i FROM Incidente i WHERE i.hora = :hora"),
    @NamedQuery(name = "Incidente.findByFecha", query = "SELECT i FROM Incidente i WHERE i.fecha = :fecha"),
    @NamedQuery(name = "Incidente.findByGravedad", query = "SELECT i FROM Incidente i WHERE i.gravedad = :gravedad"),
    @NamedQuery(name = "Incidente.findByNumeroEstacionamiento", query = "SELECT i FROM Incidente i WHERE i.numeroEstacionamiento = :numeroEstacionamiento"),
    @NamedQuery(name = "Incidente.findByPlaca", query = "SELECT i FROM Incidente i WHERE i.placa = :placa")})
public class Incidente implements Serializable {
    private static final long serialVersionUID = 1L;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @GeneratedValue(strategy=GenerationType.SEQUENCE, generator = "SQINCIDENTE")
    @SequenceGenerator(name="SQINCIDENTE", sequenceName = "SQ_INCIDENTE",allocationSize=1)
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "ID_INCIDENTE", nullable = false, precision = 0, scale = -127)
    private BigDecimal idIncidente;
    @Size(max = 100)
    @Column(name = "NOMBRE_REGISTRANTE", length = 100)
    private String nombreRegistrante;
    @Size(max = 255)
    @Column(name = "DESCRIPCION", length = 255)
    private String descripcion;
    @Column(name = "HORA")
    @Temporal(TemporalType.TIMESTAMP)
    private Date hora;
    @Column(name = "FECHA")
    @Temporal(TemporalType.TIMESTAMP)
    private Date fecha;
    @Size(max = 100)
    @Column(name = "GRAVEDAD", length = 100)
    private String gravedad;
    @Column(name = "NUMERO_ESTACIONAMIENTO")
    private BigInteger numeroEstacionamiento;
    @Column(name = "PLACA")
    private BigInteger placa;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "incidente", fetch = FetchType.EAGER)
    private Collection<MedidaCorrectiva> medidaCorrectivaCollection;
    @JoinColumn(name = "VEHICULO", referencedColumnName = "ID_VEHICULO")
    @ManyToOne(fetch = FetchType.EAGER)
    private Vehiculo vehiculo;

    public Incidente() {
    }

    public Incidente(BigDecimal idIncidente) {
        this.idIncidente = idIncidente;
    }

    public BigDecimal getIdIncidente() {
        return idIncidente;
    }

    public void setIdIncidente(BigDecimal idIncidente) {
        this.idIncidente = idIncidente;
    }

    public String getNombreRegistrante() {
        return nombreRegistrante;
    }

    public void setNombreRegistrante(String nombreRegistrante) {
        this.nombreRegistrante = nombreRegistrante;
    }

    public String getDescripcion() {
        return descripcion;
    }

    public void setDescripcion(String descripcion) {
        this.descripcion = descripcion;
    }

    public Date getHora() {
        return hora;
    }

    public void setHora(Date hora) {
        this.hora = hora;
    }

    public Date getFecha() {
        return fecha;
    }

    public void setFecha(Date fecha) {
        this.fecha = fecha;
    }

    public String getGravedad() {
        return gravedad;
    }

    public void setGravedad(String gravedad) {
        this.gravedad = gravedad;
    }

    public BigInteger getNumeroEstacionamiento() {
        return numeroEstacionamiento;
    }

    public void setNumeroEstacionamiento(BigInteger numeroEstacionamiento) {
        this.numeroEstacionamiento = numeroEstacionamiento;
    }

    public BigInteger getPlaca() {
        return placa;
    }

    public void setPlaca(BigInteger placa) {
        this.placa = placa;
    }

    @XmlTransient
    public Collection<MedidaCorrectiva> getMedidaCorrectivaCollection() {
        return medidaCorrectivaCollection;
    }

    public void setMedidaCorrectivaCollection(Collection<MedidaCorrectiva> medidaCorrectivaCollection) {
        this.medidaCorrectivaCollection = medidaCorrectivaCollection;
    }

    public Vehiculo getVehiculo() {
        return vehiculo;
    }

    public void setVehiculo(Vehiculo vehiculo) {
        this.vehiculo = vehiculo;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idIncidente != null ? idIncidente.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Incidente)) {
            return false;
        }
        Incidente other = (Incidente) object;
        if ((this.idIncidente == null && other.idIncidente != null) || (this.idIncidente != null && !this.idIncidente.equals(other.idIncidente))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "cr.ac.una.sive.entidad.Incidente[ idIncidente=" + idIncidente + " ]";
    }
    
}
